//
//  RegistVC.m
//  SchoolCircle
//
//  Created by 战立军 on 16/5/27.
//  Copyright © 2016年 战立军. All rights reserved.
//

#import "RegistVC.h"
#import "TPKeyboardAvoidingScrollView.h"
#define WH 30
@interface RegistVC ()
{
    TPKeyboardAvoidingScrollView *_scrollView;
    
    UIButton *_regisrtBtn;
    
    UITextField *_username;
    UITextField *_userpwd;
    UITextField *_userpwdrep;
    UITextField *_nickName;
    
}
@end

@implementation RegistVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _scrollView = [[TPKeyboardAvoidingScrollView alloc] initWithFrame:CGRectMake(0, 0, [UIUTils getWindowWidth], [UIUTils getWindowHeight])];
    _scrollView.backgroundColor = [UIColor whiteColor];
    // 设置内容大小
    _scrollView.contentSize = CGSizeMake([UIUTils getWindowWidth], [UIUTils getWindowHeight]);
    // 提示用户,Indicators flash
    [_scrollView flashScrollIndicators];
    [self.view addSubview:_scrollView];
    
    [self addBackView];
    
    [self addContentView];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark 添加视图

- (void)addContentView
{
    _userpwdrep = [[UITextField alloc] initWithFrame:CGRectMake(WH, self.view.center.y-40, [UIUTils getWindowWidth]-WH*2, 40)];
    _userpwdrep.borderStyle = UITextBorderStyleRoundedRect;
    _userpwdrep.backgroundColor = Color(246, 246, 246);
    _userpwdrep.placeholder = @"确认密码";
    [_scrollView addSubview:_userpwdrep];
    
    _userpwd = [[UITextField alloc] initWithFrame:CGRectMake(WH, CGRectGetMaxY(_userpwdrep.frame)-40-20-40, [UIUTils getWindowWidth]-WH*2, 40)];
    _userpwd.borderStyle = UITextBorderStyleRoundedRect;
    _userpwd.backgroundColor = Color(246, 246, 246);
    _userpwd.placeholder = @"输入密码";
    [_scrollView addSubview:_userpwd];
    
    _username = [[UITextField alloc] initWithFrame:CGRectMake(WH, CGRectGetMaxY(_userpwd.frame)-40-20-40, [UIUTils getWindowWidth]-WH*2, 40)];
    _username.borderStyle = UITextBorderStyleRoundedRect;
    _username.backgroundColor = Color(246, 246, 246);
    _username.placeholder = @"用户名";
    [_scrollView addSubview:_username];

    _nickName = [[UITextField alloc] initWithFrame:CGRectMake(WH, CGRectGetMaxY(_userpwdrep.frame)+20, [UIUTils getWindowWidth]-WH*2, 40)];
    _nickName.borderStyle = UITextBorderStyleRoundedRect;
    _nickName.backgroundColor = Color(246, 246, 246);
    _nickName.placeholder = @"昵称";
    [_scrollView addSubview:_nickName];
    
    _regisrtBtn = [UIButton buttonWithType: UIButtonTypeCustom];
    _regisrtBtn.frame = CGRectMake(WH, CGRectGetMaxY(_nickName.frame)+20, [UIUTils getWindowWidth]-WH*2, 50);
    _regisrtBtn.layer.cornerRadius =10;
    [_regisrtBtn setTitle:@"注册" forState:UIControlStateNormal];
    _regisrtBtn.backgroundColor = [UIColor redColor];
    [_regisrtBtn addTarget:self action:@selector(registButtonPress) forControlEvents:UIControlEventTouchUpInside];
    [_scrollView addSubview:_regisrtBtn];
    
}

#pragma Mark 注册
- (void)registButtonPress
{
    
}

#pragma mark 返回

- (void)addBackView
{
    UIImageView * backView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, [UIUTils getWindowWidth], 64)];
    backView.image = [UIImage imageNamed:@"uitabr"];
    UIButton *_backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _backBtn.frame = CGRectMake(5, 20, 40, 40);
    [_backBtn setBackgroundImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    [_backBtn addTarget:self action:@selector(backButtonPress) forControlEvents:UIControlEventTouchUpInside];
    backView.userInteractionEnabled = YES;
    [backView addSubview:_backBtn];
    [self.view addSubview:backView];
    
}

- (void)backButtonPress
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

@end
